#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string.h>
#include <string>
using namespace std;

class Solution {
public:
    bool backspaceCompare(string s, string t) {
        string s1;
        string s2;
        for (int i = 0; i < s.size(); i++)
        {
            if (s1.size() != 0 && s[i] == '#')  s1.pop_back();
            else if (s[i] != '#')  s1 += s[i];
        }
        for (int i = 0; i < t.size(); i++)
        {
            if (s2.size() != 0 && t[i] == '#')  s2.pop_back();
            else if (t[i] != '#')  s2 += t[i];
        }

        cout << s1 << " " << s2 << endl;
        if (strcmp(s1.c_str(), s2.c_str()) == 0)  return true;
        else  return false;
    }
};
int main()
{
    return Solution::backspaceCompare("a##c", "#a#c");
	return 0;
}